/**   
* @Title: HemaiJoinCommunicater.java 
* @Package com.esun.rabbit2.communicaters 
* @Description: TODO(通讯接口,业务标号10043)  
* @author: Kuroky Chengxt@500wan.com  
* @date: 2011-7-4 下午05:55:02  
* Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
*/
package com.esun.rabbit2.communicaters.sportterybasketball;

import java.util.ArrayList;
import java.util.HashMap;

import com.esun.config.BussinessCode;
import com.esun.config.DistributionChannels;
import com.esun.config.Key;
import com.esun.config.Language;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/** 
 * @ClassName: HemaiJoinCommunicater 
 * @Description: 竞彩篮球参与合买  
 * @author: Kuroky Chengxt@500wan.com
 * @date: 2011-8-18 下午02:55:02 
 *  
 */
public class BasketballHemaiJoinCommunicater extends ServerCommunicater{
	private String msgServer; // 服务器信息
	private boolean isSucceed = false;
	

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}
	public boolean isJoinSucceed(String lotId,String programId,String buyNum,String playId){
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(BussinessCode.PASER_MID, BussinessCode.MID_HEMAI_JOIN_BASKETBALL));
		list.add(mapItem(BussinessCode.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_LOTID, lotId));
		list.add(mapItem(Key.KEY_PID, programId));
		list.add(mapItem(Key.KEY_BUYNUM, buyNum));
		list.add(mapItem(Key.KEY_PLAYID, playId));
		list.add(mapItem(Key.KEY_CHANNEL, DistributionChannels.QUDAO));
		try {
			// 写入服务器返回信息
			super.getServerResponse(list, true);
			setMsgServer(super.getErrorMSG());
			if (super.getState() == 100) {
				isSucceed = true;
				UserInfo.getUserInfo().setUserBalance(super.getResult().get(Key.KEY_USERMONEY));
			} else {
				isSucceed = false;
			}
		} catch (Exception e) {
			isSucceed = false;
			setMsgServer(Language.STR_CONNECTIONFAIL);
		}
		return isSucceed;
	}
	/**
	 * @Title: mapItem
	 * @Description: (工具类,用于构建AraayList单条内容)
	 * @param @param name 参数名
	 * @param @param value 参数值
	 * @param @return map
	 * @return HashMap<String,String> 返回类型
	 * @throws
	 */
	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}

}
